<template>
  <el-card>
    <div slot="header" class="header">
      <span>销售额类别占比</span>
      <el-radio-group v-model="radio">
        <el-radio-button label="全部渠道"></el-radio-button>
        <el-radio-button label="线上"></el-radio-button>
        <el-radio-button label="门店"></el-radio-button>
      </el-radio-group>
    </div>
    <div>
      <div class="charts" ref="charts"></div>
    </div>
  </el-card>
</template>

<script>
import * as echarts from "echarts";
export default {
  name: "",
  data() {
    return {
      radio: "全部渠道",
    };
  },
  mounted() {
    //初始化echarts实例
    let mycharts = echarts.init(this.$refs.charts);
    let option = {
      title:{
         text:'吃饭',
         subtext:'1048',
         left:'center',
         top:'center'
      },
      tooltip: {
        //每一项的提示
        trigger: "item",
      },
      series: [
        {
          name: "Access From",
          type: "pie",
          radius: ["40%", "70%"],
          itemStyle: {
            borderColor: "#fff",
            borderWidth:2,
          },
          label: {
            show: true,
          },
          labelLine: {
            show: true,
          },
          data: [
            { value: 1048, name: "吃饭" },
            { value: 735, name: "睡觉" },
            { value: 580, name: "打豆豆" },
            { value: 484, name: "拖地" },
            { value: 300, name: "做饭" },
          ],
        },
      ],
    };
    //配置项
    mycharts.setOption(option);

    //绑定事件
    //echarts绑定
    mycharts.on('mouseover',function (params) {
         //重新配置
         mycharts.setOption({
           title:{
             text:params.data.name,
             subtext:params.data.value
           }
         })
    });
  },
};
</script>

<style scoped lang="scss">
.header {
  display: flex;
  justify-content: space-between;
  span {
    padding: 10px 0px;
    font-size: 20px;
  }
}
.charts {
  height: 278px;
}
</style>
